# _*_ coding：UTF-8 _*_
# 开发人员：lgm
# 开发时间：2021/6/17 18:21
# 文件名称：NO_3.PY
# 开发工具：PyCharm
import time
from random import randint
from selenium.webdriver.common.by import By
from new_project.xiangmu_methd import NO_4

d5_sum1 = 45
d5_sum2 = 15
d5_sum3 = 20
d5_sum4 = 15


d5_list1 = []
d5_list2 = []
d5_list3 = []
d5_list4 = []









class StartOj5:
    def __init__(self,driver):
        self.driver = driver

    def diwuxiang(self):
        self.driver.find_element(By.XPATH, "/html/body/div[2]/div/div/ul[1]/li[5]").click()  # 第二项
        time.sleep(1)
        for i in range(9):
            nub = randint(1, 5)
            """     
            / html / body / div[4] / div[2] / div / ul / li[1] / div / div / ul / li[2]
            / html / body / div[4] / div[2] / div / ul / li[2] / div / div / ul / li[6]"""
            self.driver.find_element_by_xpath(
                "/html/body/div[2]/div[2]/div/ul/li[" + str(i + 1) + "]/div/div/ul/li[" + str(nub + 1) + "]").click()
            d5_list1.append(str(nub))

        print("第五章第一小节得分明细：", d5_list1)
        d5_a_sum1 = 0
        for i in d5_list1:
            d5_a_sum1 += int(i)
        print("第五章第一小节总得分：", d5_a_sum1)
        d5_a_result1 = float(d5_a_sum1) / float(d5_sum1) * 0.2234
        print("第五章第一小节权重：", d5_a_result1)

        '''
        第二小节
        '''

        self.driver.find_element(By.XPATH, "/html/body/div[2]/div[3]/p").click() #展开菜单
        time.sleep(1)
        for i in range(3):
            nub = randint(1, 5)
            self.driver.find_element_by_xpath(
                "/html/body/div[2]/div[3]/div/ul/li[" + str(i + 1) + "]/div/div/ul/li[" + str(nub + 1) + "]").click()
            d5_list2.append(str(nub))

        print("第五章第二小节得分明细：", d5_list2)
        d5_a_sum2 = 0
        for i in d5_list2:
            d5_a_sum2 += int(i)
        print("第五章第二小节总得分：", d5_a_sum2)
        d5_a_result2 = float(d5_a_sum2) / float(d5_sum2) * 0.2594
        print("第五章第二小节权重：", d5_a_result2)
        self.driver.find_element(By.XPATH, "/html/body/div[2]/div[4]/p").click()
        time.sleep(1)
        '''
        第三小节
        '''
        for i in range(4):
            nub = randint(1, 5)
            self.driver.find_element_by_xpath(
                "/html/body/div[2]/div[4]/div/ul/li[" + str(i + 1) + "]/div/div/ul/li[" + str(nub + 1) + "]").click()
            d5_list3.append(str(nub))

        print("第五章第三小节得分明细：", d5_list3)
        d5_a_sum3 = 0
        for i in d5_list3:
            d5_a_sum3 += int(i)
        print("第五章第三小节总得分：", d5_a_sum3)
        d5_a_result3 = float(d5_a_sum3) / float(d5_sum3) * 0.2494
        print("第五章第三小节权重：", d5_a_result3)
        self.driver.find_element(By.XPATH, "/html/body/div[2]/div[5]/p").click()   #第二个div要跟着+1
        time.sleep(1)
        '''
        第四小节
        '''


        for i in range(3):
            nub = randint(1, 5)
            self.driver.find_element_by_xpath(
                "/html/body/div[2]/div[5]/div/ul/li[" + str(i + 1) + "]/div/div/ul/li[" + str(nub + 1) + "]").click()
            d5_list4.append(str(nub))

        print("第五章第四小节得分明细：", d5_list4)
        d5_a_sum4 = 0
        for i in d5_list4:
            d5_a_sum4 += int(i)
        print("第五章第四小节总得分：", d5_a_sum4)
        d5_a_result4 = float(d5_a_sum4) / float(d5_sum4) * 0.2678
        print("第五章第四小节权重：", d5_a_result4)



        print("")
        quanzhongxishu = d5_a_result1 + d5_a_result2 + d5_a_result3 + d5_a_result4
        print("权重系数总和", quanzhongxishu)

        d3_result = int(round((quanzhongxishu) * 150,0))
        print("最后结果：", d3_result)
        time.sleep(5)
        self.driver.find_element(By.XPATH, "/html/body/div[2]/input").click()
        time.sleep(2)
        d3_data = self.driver.find_element(By.XPATH, "/html/body/div[2]/div[1]/p").text
        result_data = d3_data.split(" ")
        xitong_fen = result_data[0]



        print("系统最总合计得分：", xitong_fen)
        self.driver.find_element(By.XPATH,"/html/body/div[2]/div[4]/input[2]").click()
        self.driver.implicitly_wait(20)
        return d3_result,d5_list1,d5_list2,d5_list3,d5_list4
